<?php
include ('db.php');
session_start();
$sql="SELECT * FROM msg ORDER BY id desc";
$mysqli_result=$mysql->query($sql);


//while (true){
//    $is=$mysqli_result->fetch_array(MYSQLI_ASSOC);
//    if($is==false){
//        break;
//    }
//    var_dump($is);
//}
$rows=array();
while ($is=$mysqli_result->fetch_array(MYSQLI_ASSOC)){
    $rows[]=$is;
}


?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="2.css">
</head>
<body>
<div class="add">
    <form action="http://127.0.0.1:8080/php/ziji/3/fabu.php" method="post">

        <textarea name="mazmun" class="area"></textarea>

        <input name="user" class="text" type="text">

        <input class="btn" type="submit" value="发布">
        <a style="float: right" href="login.php">登记</a>
    </form>
    <div class="msg">
        <?php
        foreach ($rows as $is) {
            $time=date('y-m-d h:s:i',$is['time'])
            ?>
                    <div class="item">
                        <span class="about <?php echo $is['id']?>"><?php echo $is['username']?></span>
                        <span class="time"><?php echo $time?>
                            <?php
                            if(isset($_SESSION['user'])) {
                                ?>
                                <a onclick="return confirm('你要确定删除吗？')" href="delete.php?id=<?php echo $is['id'] ?>">删除</a>
                                <?php
                            }
                            ?>
                        </span>
                        <p>
                            <?php echo $is['contact']?>
                        </p>
                    </div>
         <?php
            }
        ?>
    </div>
</div>
</body>
</html>